package cate.game.event.spicefb;

import cate.game.common.FastOpaqueStorage;
import cate.game.event.GameEvent;
import cate.game.role.Role;
import cate.game.role.RoleDependent;
import cate.game.role.farm.spicefb.msg.SpiceFbChallengeResultResp;
import lombok.Getter;

import java.util.Optional;

public class SpiceFbChapterUnLockedEvent extends RoleDependent implements GameEvent {

    @Getter
    private boolean unlocked;

    @Getter
    private SpiceFbChallengeResultResp resp;

    public SpiceFbChapterUnLockedEvent(Role role) {
        super(role);
    }

    public static Optional<SpiceFbChapterUnLockedEvent> current() {
        Optional<Object> current = FastOpaqueStorage.current();
        if (current.isPresent()) {
            Object opaque = current.get();
            if (opaque instanceof SpiceFbChapterUnLockedEvent) {
                return Optional.of((SpiceFbChapterUnLockedEvent) opaque);
            }
        }
        return Optional.empty();
    }

    public void setUnlocked() {
        this.unlocked = true;
    }

    public SpiceFbChapterUnLockedEvent setResp(SpiceFbChallengeResultResp resp) {
        this.resp = resp;
        return this;
    }
}

